package svgedit.gui;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Shape;

public class Rect {
	public int x1,y1,x2,y2;
	Color color,strokeColor;
	int strokeWidth;
	int width;
	int height;
	private Boolean isSelected=false;
	Shape shape;
	Graphics2D g2;
	
	public Rect() {
		this.color=Color.white;
	}
	
	public Rect(int x1,int y1,int x2,int y2,Color fillColor,Color strokeColor, int strokeWidth,
			Boolean isSelected) {
		
		this.x1=x1;
		this.x2=x2;
		this.y1=y1;
		this.y2=y2;
		this.color=fillColor;
		this.strokeColor=strokeColor;
		this.strokeWidth=strokeWidth;
		this.setIsSelected(isSelected);
	}
	
	public void draw(Graphics g) {
		Graphics2D g2 = (Graphics2D) g;
		if (getIsSelected()==true) {
			g.setColor(color);
			g.fillRect(x1, y1, x2-x1, y2-y1);
			g.setColor(Color.red);
			g.drawRect(x1, y1, x2-x1, y2-y1);
			
		}
		else {
		g.setColor(color);
		g.fillRect(x1, y1, x2-x1, y2-y1);
		g.setColor(color.black);
		g.drawRect(x1, y1, x2-x1, y2-y1);
		g2.setColor(strokeColor);
		g2.setStroke(new BasicStroke(strokeWidth));
		g2.drawRect(x1, y1, x2-x1, y2-y1);
		}
	}
	public int getStrokeWidth()
	{
		return strokeWidth;
	}
	public int getWidth() {
		return width = x2-x1;
		
	}
	public Color getFillColor()
	{
		return color;
	}
	
	public Color getStrokeColor()
	{
		return strokeColor;
	}
	public int getHeight() {
		return height=y2-y1;
	}

	public void setIsSelected(Boolean select) {
		this.isSelected = select;
	}

	public Boolean getIsSelected() {
		return isSelected;
	}
}
